<?php
header("Content-type: text/html; charset=utf-8");
require_once 'database.php';
require_once 'logfile.php';
require_once 'functions.php';
const IS_DEBUG = true;
$input = file_get_contents('php://input');
$post = json_decode($input);
$action = $post->action;
$payload = $post->payload;
if (!$action) {
    die('呵呵呵');
} elseif ($action == 'login') {
    echo json_encode(login($payload), JSON_UNESCAPED_UNICODE);
} elseif ($action == 'update_without_verify') {
    updateSingleData($payload, false);
} elseif ($action == 'update_with_verify') {
    updateSingleData($payload, true);
} elseif ($action == 'get_verify_list') {
    echo getVerifyList($payload);
} elseif ($action == 'approval') {
    operateRequest($payload, true);
} elseif ($action == 'refusal') {
    operateRequest($payload, false);
} elseif ($action == 'modify_passwd') {
    modifypasswd($payload);
} elseif ($action == 'reset_passwd') {
    resetpasswd($payload);
} elseif ($action == 'export') {
    echo json_encode(exportData($payload), JSON_UNESCAPED_UNICODE);
} elseif ($action == 'import') {
    echo json_encode(importData($payload), JSON_UNESCAPED_UNICODE);
} elseif ($action == 'get_staff_list') {
    echo json_encode(getStuff($payload), JSON_UNESCAPED_UNICODE);
} elseif ($action == 'batch_modify') {
    echo json_encode(batchModify($payload), JSON_UNESCAPED_UNICODE);
} elseif ($action == 'get_operate_log') {
    echo json_encode(getOperateLog($payload), JSON_UNESCAPED_UNICODE);
}elseif ($action == 'modify_single_data') {
    echo json_encode(modifySingleItem($payload), JSON_UNESCAPED_UNICODE);
}elseif ($action == 'delete_single_data') {
    echo json_encode(deleteSingleItem($payload), JSON_UNESCAPED_UNICODE);
}elseif ($action == 'insert_single_data') {
    echo json_encode(insertSingleItem($payload), JSON_UNESCAPED_UNICODE);
}